package noDelay;

import java.io.*;
import java.net.Socket;

public class SocketClient {
  
  public static void main(String[] args) {
    
    try {
      // 创建 客户端 socket
      Socket client = new Socket("127.0.0.1", 9090);
      
      client.setSendBufferSize(10);
      // 设置 tcpNoDelay 状态
      client.setTcpNoDelay(true);
      OutputStream out = client.getOutputStream();
      
      InputStream in = System.in;
      BufferedReader reader = new BufferedReader(new InputStreamReader(in));
      
      for (; ; ) {
        String line = reader.readLine();
        if (line != null) {
          byte[] bb = line.getBytes();
          for (byte b : bb) {
            out.write(b);
          }
        }
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}
